package integral

import (
	"context"
	"enjoy-shop/api/base"
	"enjoy-shop/formdata"
	integral2 "enjoy-shop/server/integral"
	"github.com/gin-gonic/gin"
)

func CreateIntegralRecord(c *gin.Context) {
	var integral formdata.IntegralRecord
	if err := c.ShouldBindJSON(&integral); err != nil {
		base.RespData(c, nil, err)
		return
	}
	in, err := integral2.CreateIntegralRecord(context.Background(), integral)
	if err != nil {
		base.RespData(c, nil, err)
		return
	}

	base.RespData(c, in, nil)
}
func GetIntegralRecordList(c *gin.Context) {
	var integral formdata.IntegralRecord
	if err := c.ShouldBindJSON(&integral); err != nil {
		base.RespData(c, nil, err)
		return
	}
	list, err := integral2.GetIntegralRecordList(context.Background(), integral)
	if err != nil {
		base.RespData(c, nil, err)
		return
	}

	base.RespData(c, list, nil)
}
func GerINtegralInfo(c *gin.Context) {
	var integral formdata.Integral
	if err := c.ShouldBindJSON(&integral); err != nil {
		base.RespData(c, nil, err)
		return
	}
	info, err := integral2.GetIntegralInfo(context.Background(), integral)
	if err != nil {
		base.RespData(c, nil, err)
		return
	}
	base.RespData(c, info, nil)
}
